:RUN MAKER / STANDARD COLOR GENERATOR By Andy Guevara BASIC EXPRESS, THE 3, no. 2 (May/June 1981): 15-16. One of the least documented features of BALLY BASIC that I've seen is the :RUN command to input machine language programs from tape. Nowhere is the information on how it works to be found!! Being primarily a machine language type, I felt it was time to puzzle it out of the BALLY BASIC disassembly listing. Basically, what the :RUN command does is open the tape input port and throw whatever characters come in into memory starting at address 4000 Hex (16384 Decimal), which is the first byte of screen RAM. As it loads, you can see it making tracks across the top of the screen. It continues to load bytes (by a happy coincidence an ASCII character with parity is 8 bits long) until an internal counter says stop, which it does after 128 bytes have been loaded. At this point, an immediate jump is executed to address 4000 Hex and the loaded program starts. Unfortunately it is 128 bytes, no more, no less, meaning shorter programs have to pad the ending with zeroes. Longer programs will have to incorporate the loader and direct the loading to another area in memory. What the following program does is allow a machine language program, coded in Hexadecimal, to be input and stored on tape. Once stored, all you gotta do is :INPUT and run the tape. Your program starts by itself. STANDARD COLOR GENERATOR The "Standard Color Generator" program listed following the :RUN MAKER will display a series of color bars which can be used to set the colors on your TV set. When entering this example, DO NOT enter the addresses (i.e., 4000:). They are shown only for reference. After you have keyed in the :RUN MAKER, press RUN and GO, then fill in the HEX codes as stated in the "STANDARD COLOR GENERATOR" listing, IN ORDER, by pairs, followed by GO. If finished before 128 has been entered, key-in "xx" (mult. signs) to stop the input mode. For example, the "STANDARD COLOR GENERATOR" ends with pair #69. Zero-padding to #128 is done automatically by the program. If you find a mistake too late to use the ERASE key, you can still recover by hitting the HALT key, then typing in the following: FOR N=##TO 128;G0T0 20 where ## is the number of the offending byte (make sure you type this line in without a line number!!). Notes..... A couple of notes: The ERASE key does work, but only on the current byte and looks a little funny in operation. Pressing the ERASE key will start the current byte over, placing it to the right of your original entry. Also do not be disturbed by what the Bally puts on the screen as it writes to the tape port... most of the HEX codes are not displayable as ASCII characters. The program works because the tape port gets data before the Bally Basic screen routines get a chance to change it all to "?". LAST NOTE: When running your machine language program (such as "STANDARD COLOR GENERATOR"), don't let the cursor drop so far as to cause the screen to scroll, as this will cause the program to scroll right out of memory as well. If your cursor is approaching the bottom of the screen, you can pull it up by keying in a "CY=0". The machine language program can be stopped by typing :RETURN, and restarted by typing CALL 16384. :RUN MAKER - BASIC Listing Archiving Note: This BASIC listing is in the format required by the 300-baud archiving utility TXT2PRG by Ronaldo Goulart. For example, keywords are lower- case and some symbols that aren't available on a personal computer keyboard are replaced with keywords. Notably, the multiply sign (x) is replace with "mul " in the text below. This listing was typed-in and then converted to a WAV file using both TXT2PRG and KCSWIN. 3 clear 5 for N=1to 130;@(N)=0;next N 10 print "INPUT HEX CODE, mul mul =STOP 15 for N=1to 128 20 print N,":", 25 A=KP;TV=A 27 B=KP;TV=B 30 if B=31goto 20 35 C=KP;TV=C;if C=31goto 20 36 if C#13goto 200 40 if (A=98)+(B=98)goto 100 50 C=A;gosub 250;if F=0goto 200 55 A=Cmul 16 60 C=B;gosub 250;if F=0goto 200 70 @(N)=A+C 80 next N 100 print ;print "START RECORDING...HIT ANY KEY WHEN READY 110 A=KP 120 clear ;NT=1;:print ; print ".";print ". 125 print "clear 127 print "CY=20;:run 130 for N=1to 130 135 for N=1to 130 135 for A=1to 10;next A 140 TV=@(N) 150 next N 155 clear 160 :return ;print "DONE 180 STOP 200 print "ERROR 210 goto 20 250 if (C<48)+(C>57)mul (C<65)+(C>70)F=0;return 255 F=1 260 if C<65C=C-48;return 270 C=C-55;return STANDARD COLOR GENERATOR Archiving Note: There is one error in this program on the line that reads "11 14 06 .LD DE,0C14H ; XY POSITION." This line's hex codes are correct, so typing in the program will work fine, but the line's opcode and data would not assemble to those hex codes. I've left this program as-is, but the assembly source version of this program fixes the error. Key-In Hex Pairs Hex Address Hex Pairs Comments (Ref Only) (Key-In) (Ref Only) 4000 F3 .DI FF .SYSSUK 00 .DEFB 00 ; MLTPL CALL 17 .DEFB SETOUT B6 .DEFB B6H ; BLNK LINE 13 .DEFB 13H ; R/L BNDS 08 .DEFB 08H ; INT. MODE 19 .DEFB COLSET ; SET COLORS 3C 40 .DEFW 403CH ; ADDRESS OF LIST 03 .DEFW EXIT ; STOP MULTI-CALL 01 6E 48 .LD BC,486EH ; WHITE BORDER 3E 55 .LD A,55H ; COLOR #1 11 14 06 .LD DE,0C14H ; XY POSITION FF .SYSTEM 1C .DEFB RECTAN 21 2C 40 .LD HL,402C ; LOAD TABLE ADDRESS 16 09 .LD D,09H ; BAR #1 Y POSITION 06 08 .LD B,08H ; NUMBER OF BARS C5 .PUSH BC ; SAVE COUNT 7E .LD A,(HL) ; GET COLOR FROM TABLE 23 .INC HL ; UPDATE POINTER 5E .LD E,(HL) ; GET X POS 'N FROM TABLE 23 .INC HL ; UPDATE POINTER 01 0E 42 .LD BC,420EH ; BAR SIZE FF .SYSTEM 1C .DEFB RECTAN C1 .POP BC ; GET COUNT 10 F3 .DJNZ HERE ; LOOP BACK TILL B=0 C3 9C 24 .JP 249CH ; BACK TO BASIC 402C 00 17 .COLOR TABLE--COLOR,X POS ?N 55 24 AA 33 FF 3F 00 4C 55 57 AA 64 FF 71 403C AC .GREEN 86 .YELLOW 07 .WHITE 00 .BLACK CD .CYAN 5A .RED 2B .MAGENTA F9 .BLUE Editor's Note: After you have transferred your machine language program onto tape using the :RUN MAKER program, to get the program to load the machine language software back into the Bally from tape, type in :INPUT and GO (you do not have to use the :RUN because the :RUN MAKER program placed a :RUN on tape).